/**
 * 发送请求
 **/
function doRequest(type, url, formData, async) {
    var a = (async===undefined) ? true: false;
    var token = localStorage.getItem('token');
    var dtd = $.Deferred();
    $.ajax({
        type: type,
        dataType: 'json',
        data: formData,
        async:a,
        url: url,
        headers: {'Authorization': token},
        success: function(data) {
            //console.log('data', data);
        },
        error:function(data){
            //console.log('data2', data);
        }
    }).then(function (data) {
        if (data.code === 401) {
            let r = confirm(data.msg);
            if (r) {
                window.location.href = site_url;
                return false;
            }
        }
        dtd.resolve(data);
    }, function () {
        dtd.reject();
    });
    return dtd.promise();
}